<template>
  <div class="page-mobile-school-detail">
    <white-header :isShowTopNav="true" :isShowBack="true" :isShowRight="true" :title="schoolDetail.name"></white-header>
    <div class="yx-header">
      <div class="header-left">
        <img :src="schoolDetail.ico" alt="">
      </div>
      <div class="header-right">
        <p><span style="color: #999;">所在地区：</span><span style="color: #333;">{{schoolDetail.schoolProvinceName}}</span></p>
        <p><span style="color: #999;">院校专业：</span><span style="color: #333;">{{schoolDetail.schoolCollegeMajorName}}</span></p>
        <p><span style="color: #999;">院校层次：</span><span style="color: #333;">{{schoolDetail.schoolEducationLevelName}}</span></p>
      </div>
    </div>
    <div class="yx-container">
      <div class="yx-module">
        <div class="module-title">
          院校概况
        </div>
        <div class="module-content">
          <p>{{schoolDetail.introduction}}</p>
        </div>
      </div>
      <div class="yx-module">
        <div class="module-title">
          院校简介
        </div>
        <div class="module-content">
          <p v-html="schoolDetail.details"></p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapState, mapActions, mapMutations } from "vuex";
import WhiteHeader from "~/components/mobile/WhiteHeader.vue";
import { getSchoolDetail } from "~/api/school";
export default {
  components: {
    WhiteHeader
  },
  data() {
    return {
      schoolDetail: {},
      // yx_title:'北京大学',
    };
  },
  created() {
    // this.getSchoolDetail();
  },
  mounted() {},
  activated() {
      this.getSchoolDetail();
  },
  methods: {
    ...mapMutations(["SET_IS_LOADING"]),
    formatDate(timestamp) {
      let date = new Date(timestamp);
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      let hour = date.getHours();
      let minute = date.getMinutes();
      let second = date.getSeconds();
      let add0 = (m) => {
        return m < 10 ? "0" + m : m;
      };
      let showTime = null;
      if (new Date(timestamp).toDateString() === new Date().toDateString()) {
        if (hour < 10) {
          showTime = "上午";
        } else if (hour < 12) {
          showTime = "中午";
        } else if (hour < 18) {
          showTime = "下午";
        } else {
          showTime = "晚上";
        }
        // console.log("今天", showTime + " " + add0(hour) + ":" + add0(minute));
        return showTime + " " + add0(hour) + ":" + add0(minute);
      } else {
        // console.log("以前", add0(year) + "/" + add0(month) + "/" + add0(day));
        return add0(year) + "/" + add0(month) + "/" + add0(day);
      }
    },
    //获取院校信息
    async getSchoolDetail() {
      this.SET_IS_LOADING(true);
      let id = this.$route.query.id;
      let result = await getSchoolDetail(id);
      if (result && result.data && result.data.code == 200) {
        this.schoolDetail = result.data.data;
      } else {
        this.$Message.error(this.$t("locale.pc.index.t9"));
      }
      this.SET_IS_LOADING(false);
    },
  },
};
</script>
<style lang="scss">
.page-mobile-school-detail {
  @import "~/assets/css/richtext.scss";
}
</style>
<style lang='scss' scoped>
.page-mobile-school-detail {
  min-height: 100vh;
  font-size: .3rem;
  background-color: #f7f7fa;
  .yx-header{
    width: 7.2rem;
    padding: .3072rem;
    display: flex;
    background: #ffffff;
    .header-left{
      width: 1.536rem;
      height: 1.536rem;
      margin-right: .4rem;
      img{
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background: var(--theme-color);
        display: block;
        overflow: hidden;
      }
    }
    .header-right{
      width: 4.6rem;
      p{
        line-height: .5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
  .yx-container{
    background: #ffffff;
    padding: .3rem;
    margin-top: .2rem;
    .yx-module{
      margin-bottom: .2rem;
      min-height: 2rem;
      .module-title{
        color: #333;
        font-weight: bold;
        padding-left: .3rem;
        position: relative;
        margin-bottom: .2rem;
        &::after{
          position: absolute;
          content: "";
          display: block;
          left: 0;
          top: 0;
          width: .1rem;
          height: 100%;
          background: var(--theme-color);
        }
      }
      .module-content{
        line-height: .4rem;
      }
    }
  }
}
</style>